import java.util.Calendar;

public class Tool {

    /*public void updateFourth(double amount, String reason) {
        Calendar calendar = Calendar.getInstance();
        String date = String.format("%-11s", calendar.get(Calendar.DAY_OF_MONTH) + "日");
        String type = amount > 0 ? "收入" : "支出";
        String formattedAmount = String.format("%-28s", String.valueOf(amount));
        String formattedReason = String.format("%-20s", reason);

        String entry = String.format("%-11s%-14s%-28s%-20s\n", date, type, formattedAmount, formattedReason);

        //FourthWindow.detailsBuilder.append(entry);
        //FourthWindow.detailsTextArea.setText(FourthWindow.detailsBuilder.toString());





    }*/


    public void updateMainWindowData1(double incomeAmount) {
        // 获取当前主窗口数据
        double remaining = Double.parseDouble(FirstWindow.remainingLabel.getText().substring(5));
        int daysLeft = Integer.parseInt(FirstWindow.daysLeftLabel.getText().substring(8));


        // 更新数据
        remaining += incomeAmount;


        // 更新主窗口显示
        FirstWindow.remainingLabel.setText("本月剩余：" + remaining);
        FirstWindow.daysLeftLabel.setText("距离本月末天数：" + daysLeft);
    }

    public void updateMainWindowData2(double expenseAmount) {
        // 获取当前主窗口数据
        double remaining = Double.parseDouble(FirstWindow.remainingLabel.getText().substring(5));
        double expense = Double.parseDouble(FirstWindow.expenseLabel.getText().substring(5));
        int daysLeft = Integer.parseInt(FirstWindow.daysLeftLabel.getText().substring(8));
        double todayExpense = Double.parseDouble(FirstWindow.todayExpenseLabel.getText().substring(7));

        // 更新数据
        remaining += expenseAmount;
        expense += expenseAmount;
        expense = -expense;
        todayExpense += expenseAmount;
        todayExpense = -todayExpense;


        // 更新主窗口显示
        FirstWindow.remainingLabel.setText("本月剩余：" + remaining);
        FirstWindow.expenseLabel.setText("本月消费：" + expense);
        FirstWindow.daysLeftLabel.setText("距离本月末天数：" + daysLeft);
        FirstWindow.todayExpenseLabel.setText("今日消费金额：" + todayExpense);
    }

}
